const path = require('path');
const HtmlWebPackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: './entry.js',
    output: {
        path: path.resolve(__dirname, './build'),
        filename: 'assets/bundle-[hash].js',
    },
    module: {
        rules: [{
            test: /\.test\.js$/,
            use: ['babel-loader', 'mocha-loader'],
            exclude: /node_modules/
        }, {
            test: /\.html$/,
            use: [{
                loader: 'html-loader',
                options: { minimize: true },
            }],
        }]
    },
    plugins: [
        new HtmlWebPackPlugin({
            filename: 'index.html',
            template: './public/index.html',
            minify: {
                removeRedundantAttributes: true,
                collapseWhitespace: true,
                removeAttributeQuotes: true,
                removeComments: true,
                collapseBooleanAttributes: true,
            },
            favicon: '',
            hash: true,
        }),
    ]
}